package com.remind;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;

public class SendMessageService extends Service implements Handler.Callback {

    private static final String TAG = "SendMessageService";

    private Handler handler = new Handler(this) ;

    public SendMessageService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.i(TAG, "onBind: ");
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public void onCreate() {
        Log.i(TAG, "onCreate: ");
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand: ");
        handler.sendEmptyMessageDelayed(0,3000) ;
        return START_STICKY;
    }


    @Override
    public void onDestroy() {
        Log.i(TAG, "onDestroy: ");
        super.onDestroy();
    }

    @Override
    public boolean handleMessage(Message msg) {
        Intent intent = new Intent();
        intent.setAction("com.remind.ReciveMessage");
        sendBroadcast(intent); //发送广播
        handler.sendEmptyMessageDelayed(0,3000) ;
        return false;
    }
}
